1 module opensles.android;
2 public import opensles.android_configuration;
3 public import opensles.android_metadata;
4 alias jobject = void*;
5 
6 /*
7  * Copyright (C) 2010 The Android Open Source Project
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */
21 
22 import opensles.sles; //#include "OpenSLES.h"
23 import opensles.android_configuration;//#include "OpenSLES_AndroidConfiguration.h" //
24 import opensles.android_metadata;// #include "OpenSLES_AndroidMetadata.h"
25 // #include <jni.h>
26 
27 /*---------------------------------------------------------------------------*/
28 /* Android common types                                                      */
29 /*---------------------------------------------------------------------------*/
30 
31 extern(C):
32 alias SLAint64 = const(const(sl_int64_t*));          /* 64 bit signed integer   */
33 
34 alias SLAuint64 = const(const(sl_uint64_t*));         /* 64 bit unsigned integer */
35 
36 /*---------------------------------------------------------------------------*/
37 /* Android PCM Data Format                                                   */
38 /*---------------------------------------------------------------------------*/
39 
40 /* The following pcm representations and data formats map to those in OpenSLES 1.1 */
41 enum SL_ANDROID_PCM_REPRESENTATION_SIGNED_INT   =      (cast(SLuint32) 0x00000001);
42 enum SL_ANDROID_PCM_REPRESENTATION_UNSIGNED_INT =      (cast(SLuint32) 0x00000002);
43 enum SL_ANDROID_PCM_REPRESENTATION_FLOAT        =      (cast(SLuint32) 0x00000003);
44 
45 enum SL_ANDROID_DATAFORMAT_PCM_EX               =     (cast(SLuint32) 0x00000004);
46 
47 struct SLAndroidDataFormat_PCM_EX {
48     SLuint32         formatType;
49     SLuint32         numChannels;
50     SLuint32         sampleRate;
51     SLuint32         bitsPerSample;
52     SLuint32         containerSize;
53     SLuint32         channelMask;
54     SLuint32         endianness;
55     SLuint32         representation;
56 
57     ///Maintain struct naming based on SLDataFormat_PCM
58     alias samplesPerSec = sampleRate;
59 }
60 
61 enum SL_ANDROID_SPEAKER_NON_POSITIONAL =       (cast(SLuint32) 0x80000000);
62 
63 // Make an indexed channel mask from a bitfield.
64 //
65 // Each bit in the bitfield corresponds to a channel index,
66 // from least-significant bit (channel 0) up to the bit
67 // corresponding to the maximum channel count (currently FCC_8).
68 // A '1' in the bitfield indicates that the channel should be
69 // included in the stream, while a '0' indicates that it
70 // should be excluded. For instance, a bitfield of 0x0A (binary 00001010)
71 // would define a stream that contains channels 1 and 3. (The corresponding
72 // indexed mask, after setting the SL_ANDROID_NON_POSITIONAL bit,
73 // would be 0x8000000A.)
74 enum SL_ANDROID_MAKE_INDEXED_CHANNEL_MASK(int bitfield)
75 {
76     return ((bitfield) | SL_ANDROID_SPEAKER_NON_POSITIONAL);
77 }
78 
79 // Specifying SL_ANDROID_SPEAKER_USE_DEFAULT as a channel mask in
80 // SLAndroidDataFormat_PCM_EX causes OpenSL ES to assign a default
81 // channel mask based on the number of channels requested. This
82 // value cannot be combined with SL_ANDROID_SPEAKER_NON_POSITIONAL.
83 enum SL_ANDROID_SPEAKER_USE_DEFAULT =  (cast(SLuint32)0);
84 
85 /*---------------------------------------------------------------------------*/
86 /* Android Effect interface                                                  */
87 /*---------------------------------------------------------------------------*/
88 
89 extern __gshared const(const(SLInterfaceID_)*) SL_IID_ANDROIDEFFECT;
90 
91 /** Android Effect interface methods */
92 
93 struct SLAndroidEffectItf_ {
94 
95     SLresult function(SLAndroidEffectItf self, SLInterfaceID effectImplementationId) CreateEffect;
96     SLresult function (SLAndroidEffectItf self,SLInterfaceID effectImplementationId) ReleaseEffect;
97     SLresult function (SLAndroidEffectItf self, SLInterfaceID effectImplementationId, SLboolean enabled) SetEnabled;
98 
99     SLresult function (SLAndroidEffectItf self,
100             SLInterfaceID effectImplementationId,
101             SLboolean *pEnabled) IsEnabled;
102 
103     SLresult function (SLAndroidEffectItf self,
104             SLInterfaceID effectImplementationId,
105             SLuint32 command,
106             SLuint32 commandSize,
107             void *pCommandData,
108             SLuint32 *replySize,
109             void *pReplyData) SendCommand;
110 }
111 alias SLAndroidEffectItf = const(const(SLAndroidEffectItf_)*)*;
112 
113 
114 /*---------------------------------------------------------------------------*/
115 /* Android Effect Send interface                                             */
116 /*---------------------------------------------------------------------------*/
117 
118 extern __gshared const(const(SLInterfaceID_)*) SL_IID_ANDROIDEFFECTSEND;
119 
120 /** Android Effect Send interface methods */
121 
122 
123 struct SLAndroidEffectSendItf_ {
124     SLresult function(
125         SLAndroidEffectSendItf self,
126         SLInterfaceID effectImplementationId,
127         SLboolean enable,
128         SLmillibel initialLevel
129     ) EnableEffectSend;
130     SLresult function (
131         SLAndroidEffectSendItf self,
132         SLInterfaceID effectImplementationId,
133         SLboolean *pEnable
134     ) IsEnabled;
135     SLresult function (
136         SLAndroidEffectSendItf self,
137         SLmillibel directLevel
138     ) SetDirectLevel;
139     SLresult function (
140         SLAndroidEffectSendItf self,
141         SLmillibel *pDirectLevel
142     ) GetDirectLevel;
143     SLresult function (
144         SLAndroidEffectSendItf self,
145         SLInterfaceID effectImplementationId,
146         SLmillibel sendLevel
147     ) SetSendLevel;
148     SLresult function (
149         SLAndroidEffectSendItf self,
150         SLInterfaceID effectImplementationId,
151         SLmillibel *pSendLevel
152     ) GetSendLevel;
153 }
154 alias SLAndroidEffectSendItf = const(const(SLAndroidEffectSendItf_)*)*;
155 
156 
157 /*---------------------------------------------------------------------------*/
158 /* Android Effect Capabilities interface                                     */
159 /*---------------------------------------------------------------------------*/
160 
161 extern __gshared const(const(SLInterfaceID_)*) SL_IID_ANDROIDEFFECTCAPABILITIES;
162 
163 /** Android Effect Capabilities interface methods */
164 
165 
166 struct SLAndroidEffectCapabilitiesItf_ {
167 
168     SLresult function (SLAndroidEffectCapabilitiesItf self,
169             SLuint32 *pNumSupportedEffects) QueryNumEffects;
170 
171 
172     SLresult function (SLAndroidEffectCapabilitiesItf self,
173             SLuint32 index,
174             SLInterfaceID *pEffectType,
175             SLInterfaceID *pEffectImplementation,
176             SLchar *pName,
177             SLuint16 *pNameSize) QueryEffect;
178 }
179 alias SLAndroidEffectCapabilitiesItf = const(const(SLAndroidEffectCapabilitiesItf_)*)*;
180 
181 
182 /*---------------------------------------------------------------------------*/
183 /* Android Configuration interface                                           */
184 /*---------------------------------------------------------------------------*/
185 extern __gshared const(const(SLInterfaceID_)*) SL_IID_ANDROIDCONFIGURATION;
186 
187 /** Android Configuration interface methods */
188 
189 
190 /*
191  * Java Proxy Type IDs
192  */
193 enum SL_ANDROID_JAVA_PROXY_ROUTING = 0x0001;
194 
195 struct SLAndroidConfigurationItf_ {
196 
197     SLresult function (SLAndroidConfigurationItf self,
198             const SLchar *configKey,
199             const void *pConfigValue,
200             SLuint32 valueSize) SetConfiguration;
201 
202     SLresult function (SLAndroidConfigurationItf self,
203            const SLchar *configKey,
204            SLuint32 *pValueSize,
205            void *pConfigValue
206        ) GetConfiguration;
207 
208     SLresult function (SLAndroidConfigurationItf self,
209             SLuint32 proxyType,
210             jobject *pProxyObj) AcquireJavaProxy;
211 
212     SLresult function (SLAndroidConfigurationItf self,
213             SLuint32 proxyType) ReleaseJavaProxy;
214 }
215 alias SLAndroidConfigurationItf = const(const(SLAndroidConfigurationItf_)*)*;
216 
217 
218 /*---------------------------------------------------------------------------*/
219 /* Android Simple Buffer Queue Interface                                     */
220 /*---------------------------------------------------------------------------*/
221 
222 extern __gshared const(const(SLInterfaceID_)*) SL_IID_ANDROIDSIMPLEBUFFERQUEUE;
223 alias /*SLAPIENTRY*/slAndroidSimpleBufferQueueCallback = extern(C) void function(SLAndroidSimpleBufferQueueItf caller, void* pContext);
224 
225 struct SLAndroidSimpleBufferQueueItf_ {
226 	SLresult function (
227 		SLAndroidSimpleBufferQueueItf self,
228 		const void *pBuffer,
229 		SLuint32 size
230 	) Enqueue;
231 	SLresult function (
232 		SLAndroidSimpleBufferQueueItf self
233 	) Clear;
234 	SLresult function (
235 		SLAndroidSimpleBufferQueueItf self,
236 		SLAndroidSimpleBufferQueueState *pState
237 	) GetState;
238     extern(C) SLresult function (
239 		SLAndroidSimpleBufferQueueItf self,
240 		slAndroidSimpleBufferQueueCallback callback,
241 		void* pContext
242 	) RegisterCallback;
243 
244 	// SLresult function (
245 	// 	SLAndroidSimpleBufferQueueItf self,
246 	// 	slAndroidSimpleBufferQueueCallback callback,
247 	// 	void* pContext
248 	// ) RegisterCallback;
249 }
250 alias SLAndroidSimpleBufferQueueItf = const(const(SLAndroidSimpleBufferQueueItf_)*)*;
251 
252 /** Android simple buffer queue state **/
253 struct SLAndroidSimpleBufferQueueState {
254 	SLuint32	count;
255 	SLuint32	index;
256 }
257 
258 
259 /*---------------------------------------------------------------------------*/
260 /* Android Buffer Queue Interface                                            */
261 /*---------------------------------------------------------------------------*/
262 
263 extern __gshared const(const(SLInterfaceID_)*) SL_IID_ANDROIDBUFFERQUEUESOURCE;
264 
265 
266 enum SL_ANDROID_ITEMKEY_NONE              = (cast(SLuint32) 0x00000000);
267 enum SL_ANDROID_ITEMKEY_EOS               = (cast(SLuint32) 0x00000001);
268 enum SL_ANDROID_ITEMKEY_DISCONTINUITY     = (cast(SLuint32) 0x00000002);
269 enum SL_ANDROID_ITEMKEY_BUFFERQUEUEEVENT  = (cast(SLuint32) 0x00000003);
270 enum SL_ANDROID_ITEMKEY_FORMAT_CHANGE     = (cast(SLuint32) 0x00000004);
271 
272 enum SL_ANDROIDBUFFERQUEUEEVENT_NONE         = (cast(SLuint32) 0x00000000);
273 enum SL_ANDROIDBUFFERQUEUEEVENT_PROCESSED    = (cast(SLuint32) 0x00000001);
274 static if(0) // reserved for future use
275 {
276     enum SL_ANDROIDBUFFERQUEUEEVENT_UNREALIZED   = (cast(SLuint32) 0x00000002);
277     enum SL_ANDROIDBUFFERQUEUEEVENT_CLEARED      = (cast(SLuint32) 0x00000004);
278     enum SL_ANDROIDBUFFERQUEUEEVENT_STOPPED      = (cast(SLuint32) 0x00000008);
279     enum SL_ANDROIDBUFFERQUEUEEVENT_ERROR        = (cast(SLuint32) 0x00000010);
280     enum SL_ANDROIDBUFFERQUEUEEVENT_CONTENT_END  = (cast(SLuint32) 0x00000020);
281 }   
282 
283 struct SLAndroidBufferItem {
284     SLuint32 itemKey;  // identifies the item
285     SLuint32 itemSize;
286     SLuint8[0]  itemData;
287 }
288 
289 alias /*SLAPIENTRY*/ slAndroidBufferQueueCallback = SLresult function(
290     SLAndroidBufferQueueItf caller,/* input */
291     void *pCallbackContext,        /* input */
292     void *pBufferContext,          /* input */
293     void *pBufferData,             /* input */
294     SLuint32 dataSize,             /* input */
295     SLuint32 dataUsed,             /* input */
296     const SLAndroidBufferItem *pItems,/* input */
297     SLuint32 itemsLength           /* input */
298 );
299 
300 struct SLAndroidBufferQueueState {
301     SLuint32    count;
302     SLuint32    index;
303 }
304 
305 struct SLAndroidBufferQueueItf_ {
306     SLresult function (
307         SLAndroidBufferQueueItf self,
308         slAndroidBufferQueueCallback callback,
309         void* pCallbackContext
310     ) RegisterCallback;
311 
312     SLresult function (
313         SLAndroidBufferQueueItf self
314     ) Clear;
315 
316     SLresult function (
317         SLAndroidBufferQueueItf self,
318         void *pBufferContext,
319         void *pData,
320         SLuint32 dataLength,
321         const SLAndroidBufferItem *pItems,
322         SLuint32 itemsLength
323     ) Enqueue;
324 
325     SLresult function (
326         SLAndroidBufferQueueItf self,
327         SLAndroidBufferQueueState *pState
328     ) GetState;
329 
330     SLresult function (
331             SLAndroidBufferQueueItf self,
332             SLuint32 eventFlags
333     ) SetCallbackEventsMask;
334 
335     SLresult function (
336             SLAndroidBufferQueueItf self,
337             SLuint32 *pEventFlags
338     ) GetCallbackEventsMask;
339 }
340 alias SLAndroidBufferQueueItf = const(const(SLAndroidBufferQueueItf_)*)*;
341 
342 
343 /*---------------------------------------------------------------------------*/
344 /* Android File Descriptor Data Locator                                      */
345 /*---------------------------------------------------------------------------*/
346 
347 /** Addendum to Data locator macros  */
348 enum SL_DATALOCATOR_ANDROIDFD =                (cast(SLuint32) 0x800007BC);
349 
350 /**long long value*/
351 enum SL_DATALOCATOR_ANDROIDFD_USE_FILE_SIZE = (cast(SLAint64) 0xFFFFFFFFFFFFFFFF);
352 
353 /** File Descriptor-based data locator definition, locatorType must be SL_DATALOCATOR_ANDROIDFD */
354 struct SLDataLocator_AndroidFD {
355     SLuint32        locatorType;
356     SLint32         fd;
357     SLAint64        offset;
358     SLAint64        length;
359 }
360 
361 
362 /*---------------------------------------------------------------------------*/
363 /* Android Android Simple Buffer Queue Data Locator                          */
364 /*---------------------------------------------------------------------------*/
365 
366 /** Addendum to Data locator macros  */
367 enum SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE = (cast(SLuint32) 0x800007BD);
368 
369 /** BufferQueue-based data locator definition where locatorType must
370  *  be SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE
371  */
372 struct SLDataLocator_AndroidSimpleBufferQueue {
373 	SLuint32	locatorType;
374 	SLuint32	numBuffers;
375 }
376 
377 
378 /*---------------------------------------------------------------------------*/
379 /* Android Buffer Queue Data Locator                                         */
380 /*---------------------------------------------------------------------------*/
381 
382 /** Addendum to Data locator macros  */
383 enum SL_DATALOCATOR_ANDROIDBUFFERQUEUE = (cast(SLuint32) 0x800007BE);
384 
385 /** Android Buffer Queue-based data locator definition,
386  *  locatorType must be SL_DATALOCATOR_ANDROIDBUFFERQUEUE */
387 struct SLDataLocator_AndroidBufferQueue {
388     SLuint32    locatorType;
389     SLuint32    numBuffers;
390 }
391 
392 /**
393  * MIME types required for data in Android Buffer Queues
394  */
395 enum SL_ANDROID_MIME_AACADTS = (cast(SLchar *) "audio/vnd.android.aac-adts");
396 
397 /*---------------------------------------------------------------------------*/
398 /* Acoustic Echo Cancellation (AEC) Interface                                */
399 /* --------------------------------------------------------------------------*/
400 extern __gshared const(const(SLInterfaceID_)*) SL_IID_ANDROIDACOUSTICECHOCANCELLATION;
401 
402 
403 struct SLAndroidAcousticEchoCancellationItf_ {
404     SLresult function (
405         SLAndroidAcousticEchoCancellationItf self,
406         SLboolean enabled
407     ) SetEnabled;
408     SLresult function (
409         SLAndroidAcousticEchoCancellationItf self,
410         SLboolean *pEnabled
411     ) IsEnabled;
412 }
413 alias SLAndroidAcousticEchoCancellationItf = const(const(SLAndroidAcousticEchoCancellationItf_)*)*;
414 
415 /*---------------------------------------------------------------------------*/
416 /* Automatic Gain Control (ACC) Interface                                    */
417 /* --------------------------------------------------------------------------*/
418 extern __gshared const(const(SLInterfaceID_)*) SL_IID_ANDROIDAUTOMATICGAINCONTROL;
419 
420 
421 struct SLAndroidAutomaticGainControlItf_ {
422     SLresult function (
423         SLAndroidAutomaticGainControlItf self,
424         SLboolean enabled
425     ) SetEnabled;
426     SLresult function (
427         SLAndroidAutomaticGainControlItf self,
428         SLboolean *pEnabled
429     ) IsEnabled;
430 }
431 alias SLAndroidAutomaticGainControlItf = const(const(SLAndroidAutomaticGainControlItf_)*)*;
432 
433 /*---------------------------------------------------------------------------*/
434 /* Noise Suppression Interface                                               */
435 /* --------------------------------------------------------------------------*/
436 extern __gshared const(const(SLInterfaceID_)*) SL_IID_ANDROIDNOISESUPPRESSION;
437 
438 
439 struct SLAndroidNoiseSuppressionItf_ {
440     SLresult function (
441         SLAndroidNoiseSuppressionItf self,
442         SLboolean enabled
443     ) SetEnabled;
444     SLresult function (
445         SLAndroidNoiseSuppressionItf self,
446         SLboolean *pEnabled
447     ) IsEnabled;
448 }
449 alias SLAndroidNoiseSuppressionItf = const(const(SLAndroidNoiseSuppressionItf_)*)*;